package com.atguigu.spzx.manager.service.Impl;

import com.atguigu.spzx.manager.mapper.ProductDetailsMapper;
import com.atguigu.spzx.manager.service.ProductDetailsService;
import com.atguigu.spzx.model.entity.product.ProductDetails;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * ClassName: ProductDetailsServiceImpl
 * Package: com.atguigu.spzx.manager.service.Impl
 * Description:
 *
 * @Author 刘强
 * @Create 2024/7/6 16:32
 * @Version 1.0
 */
@Service
public class ProductDetailsServiceImpl implements ProductDetailsService {
    @Resource
    private ProductDetailsMapper productDetailsMapper;
    /**
     * 保存商品详情
     * @param productDetails
     */
    @Override
    public void save(ProductDetails productDetails) {
        productDetailsMapper.save(productDetails);
    }

    /**
     * 根据productId获取productDetails
     * @param id
     * @return
     */
    @Override
    public ProductDetails getByProductId(Long id) {
        return productDetailsMapper.getByProductId(id);
    }

    /**
     * 根据id修改
     * @param productDetails
     */
    @Override
    public void updateById(ProductDetails productDetails) {
        productDetails.setUpdateTime(new Date());
        productDetailsMapper.updateById(productDetails);
    }

    /**
     * 根据productId删除
     * @param productId
     */
    @Override
    public void deleteByProductId(Long productId) {
        productDetailsMapper.deleteByProductId(productId);
    }
}
